/*
 * =====================================================================================
 *
 *       Filename:  string.h
 *
 *    Description:  string operate
 *
 *        Version:  1.0
 *        Created:  2013年03月06日 15时47分39秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  jianxi sun (jianxi), ycsunjane@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */

#define BUF_LEN 20
/*
 * strcmp - compare two string
 * return: 
 *       if str1 equal str2 then return 0,else return -1
 * */
static inline int strcmp(char *str1,char *str2)
{
	int i=0;
	do{
		if(str1[i] == str2[i])
			continue;
		else
			return -1;
	}while(str1[i++] != '\0');
	return 0;
}

static inline char* itoa(int val)
{
	int i = BUF_LEN;
	static char buf[BUF_LEN+1] = {0};
	for(;val && i;--i,val/=10)
		buf[i]="0123456789"[val%10];
	
	return &buf[i+1];
}

void bin_echo(char data)
{
	int test = 1;
	int i;
	for(i = 7; i >= 0; i--){
		if(data & (test << i))
			printf("1");
		else
			printf("0");
	}
	printf("\n");
}
